package com.oscar.ehome.view.pageview.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.oscar.ehome.R;
import com.oscar.ehome.bean.pagebean.tuanduiBean;

import java.util.List;

/**
 * Created by juxing
 * author: MengWanhe
 * date: On 2017/11/23
 */

public class TuanDuiAdapter extends BaseAdapter {

    private List<tuanduiBean.ss> specailList;
    int colnum = 1;
    private LayoutInflater mInflater;
    private Context mContext = null;

    public TuanDuiAdapter(Context context, int colnum, List<tuanduiBean.ss> list) {
        this.mContext = context;
        this.colnum = colnum;
        this.specailList = list;
        mInflater = LayoutInflater.from(context);
    }

    public void setList(List<tuanduiBean.ss> list) {
        this.specailList = list;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return specailList.size();
    }

    @Override
    public Object getItem(int position) {
        return specailList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        TuanDuiAdapter.ViewHolder holder;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.tuanduiitem, null);
            holder = new TuanDuiAdapter.ViewHolder();
            holder.count = (TextView) convertView.findViewById(R.id.count);
            holder.name = (TextView) convertView.findViewById(R.id.name);


            convertView.setTag(holder); //
        } else {
            holder = (TuanDuiAdapter.ViewHolder) convertView.getTag(); //
        }

        tuanduiBean.ss bean = specailList.get(position);
        holder.name.setText(bean.getRoleMobile().getRoleName());
        if(bean.getRoleMobileUserNum()!=0&&!"".equals(bean.getRoleMobileUserNum())){
            holder.count.setText(bean.getRoleMobileUserNum()+"");
        }else {
            holder.count.setText("0");
        }



        return convertView;
    }

    class ViewHolder {
        TextView count;
        TextView name;

    }

}
